package com.moshang.blog.core.constant;

import org.apache.shiro.SecurityUtils;

/**
 *
 * @author moshang
 * @date 2017/11/25
 * todo:
 */
public class MySysUser {
    /**
     * 取出Shiro中的当前用户LoginName.
     */
    public static String image() {
        return currentUser().getImage();
    }

    public static Integer id() {
        return currentUser().getId();
    }

    public static String userName() {
        return currentUser().getUserName();
    }

    public static String realName(){
        return currentUser().getRealName();
    }

    public static CurrentUser currentUser() {
        CurrentUser user = (CurrentUser) SecurityUtils.getSubject().getPrincipals().getPrimaryPrincipal();
        return user;
    }
}
